angular.module('mamApp').factory('messageManager', ['$http', 'api', function ($http, api) {
    var messageManager = {
        /**
         * 获取消息列表
         * @param params
         * @returns
         */

        messageList: function (pageNo, pageSize) {
            return $http.get(api + '/cp/messages/' + pageNo + '/' + pageSize).then(function (result) {
                return result;
            });
        },
        /**
         * 获取单个消息详情
         * @param params
         * @returns result
         */
        messageDetail: function (messageId) {
            return $http.get(api + '/cp/messages/' + messageId).then(function (result) {
                return result;
            });
        },

        /**
         * 删除单个消息
         * @returns result
         */
        messageDelete: function (messageId) {
            return $http.delete(api + '/cp/messages/' + messageId).then(function (result) {
                return result;
            });
        },

        /**
         * 更新单个消息已读未读状态
         * @returns result
         */
        messageStatus: function (messageId) {
            return $http.put(api + '/cp/messages/' + messageId).then(function (result) {
                return result;
            });
        },

        /**
         * 获取未读消息数量
         * @returns result
         */
        messageUnRead: function () {
            return $http.get(api + '/cp/unremessages').then(function (result) {
                return result;
            });
        },

        /**
         * 获取未读消息数量
         * @returns result
         */
        messageAllRead: function () {
            return $http.put(api + '/cp/unmamessages').then(function (result) {
                return result;
            });
        }


    };

    return messageManager;
}]);
